Skip to content

[EDR Workflows] Speed up MS Defender runscript Jest tests by mocking p-retry#268311

Merged
szwarckonrad merged 4 commits into
elastic:mainfrom
szwarckonrad:fix-ms-defender-runscript-slow-tests
May 11, 2026
Merged

[EDR Workflows] Speed up MS Defender runscript Jest tests by mocking p-retry#268311
szwarckonrad merged 4 commits into
elastic:mainfrom
szwarckonrad:fix-ms-defender-runscript-slow-tests

Conversation

@szwarckonrad
Copy link
Copy Markdown
Contributor

@szwarckonrad szwarckonrad commented May 7, 2026

Summary

Two tests in ms_defender_endpoint_actions_client.test.ts (should throw error when GET_ACTIONS returns no action details after retry and should throw error when GET_ACTIONS call fails) intermittently exceeded Jest's 5s default. Both exercise the production retry path in fetchAndValidateRunscriptActionDetails, which uses pRetry with retries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5 — ~4s of real-time sleep before the outer catch returns Action details not found.

This PR mocks p-retry at the file level (delegating to the real implementation by default), and short-circuits it with mockImplementationOnce(async (fn) => fn(1)) in the two slow tests. Mirrors the existing pattern in license_watch.test.ts and reference_data/helpers.test.ts. The two // TODO: Fix this slow test markers are removed.

@szwarckonrad szwarckonrad added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:Defend Workflows “EDR Workflows” sub-team of Security Solution labels May 7, 2026
@szwarckonrad szwarckonrad self-assigned this May 7, 2026
@szwarckonrad szwarckonrad marked this pull request as ready for review May 8, 2026 16:22
@szwarckonrad szwarckonrad requested a review from a team as a code owner May 8, 2026 16:22
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/security-defend-workflows (Team:Defend Workflows)

Copy link
Copy Markdown
Contributor

@gergoabraham gergoabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@szwarckonrad szwarckonrad enabled auto-merge (squash) May 11, 2026 17:33
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @szwarckonrad

@szwarckonrad szwarckonrad merged commit b4c8ba7 into elastic:main May 11, 2026
31 checks passed
clintandrewhall pushed a commit that referenced this pull request May 12, 2026
…p-retry (#268311)

## Summary

Two tests in `ms_defender_endpoint_actions_client.test.ts` (`should
throw error when GET_ACTIONS returns no action details after retry` and
`should throw error when GET_ACTIONS call fails`) intermittently
exceeded Jest's 5s default. Both exercise the production retry path in
`fetchAndValidateRunscriptActionDetails`, which uses `pRetry` with
`retries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5` — ~4s of
real-time sleep before the outer catch returns `Action details not
found`.

This PR mocks `p-retry` at the file level (delegating to the real
implementation by default), and short-circuits it with
`mockImplementationOnce(async (fn) => fn(1))` in the two slow tests.
Mirrors the existing pattern in `license_watch.test.ts` and
`reference_data/helpers.test.ts`. The two `// TODO: Fix this slow test`
markers are removed.
patrykkopycinski pushed a commit to patrykkopycinski/kibana that referenced this pull request May 13, 2026
…p-retry (elastic#268311)

## Summary

Two tests in `ms_defender_endpoint_actions_client.test.ts` (`should
throw error when GET_ACTIONS returns no action details after retry` and
`should throw error when GET_ACTIONS call fails`) intermittently
exceeded Jest's 5s default. Both exercise the production retry path in
`fetchAndValidateRunscriptActionDetails`, which uses `pRetry` with
`retries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5` — ~4s of
real-time sleep before the outer catch returns `Action details not
found`.

This PR mocks `p-retry` at the file level (delegating to the real
implementation by default), and short-circuits it with
`mockImplementationOnce(async (fn) => fn(1))` in the two slow tests.
Mirrors the existing pattern in `license_watch.test.ts` and
`reference_data/helpers.test.ts`. The two `// TODO: Fix this slow test`
markers are removed.
jcger pushed a commit that referenced this pull request May 26, 2026
…p-retry (#268311)

## Summary

Two tests in `ms_defender_endpoint_actions_client.test.ts` (`should
throw error when GET_ACTIONS returns no action details after retry` and
`should throw error when GET_ACTIONS call fails`) intermittently
exceeded Jest's 5s default. Both exercise the production retry path in
`fetchAndValidateRunscriptActionDetails`, which uses `pRetry` with
`retries: 5, minTimeout: 300, maxTimeout: 1500, factor: 1.5` — ~4s of
real-time sleep before the outer catch returns `Action details not
found`.

This PR mocks `p-retry` at the file level (delegating to the real
implementation by default), and short-circuits it with
`mockImplementationOnce(async (fn) => fn(1))` in the two slow tests.
Mirrors the existing pattern in `license_watch.test.ts` and
`reference_data/helpers.test.ts`. The two `// TODO: Fix this slow test`
markers are removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants